how to get the history of an work item?
Hi,
Does anybody know how to get the history of an work item? By history, I mean changes to a given work item. I tried IAuditable.getPredecessorState on an IWorkItem, but when I attempted to get the fields of the predecessor state, I got an IllegalStateException. The error message says "Attempting to get unset feature: InternalState". It's clear that I'm not doing things right, but I have no idea how I should do it correctly. Please help! Thanks!
Annie
Does anybody know how to get the history of an work item? By history, I mean changes to a given work item. I tried IAuditable.getPredecessorState on an IWorkItem, but when I attempted to get the fields of the predecessor state, I got an IllegalStateException. The error message says "Attempting to get unset feature: InternalState". It's clear that I'm not doing things right, but I have no idea how I should do it correctly. Please help! Thanks!
Annie
Accepted answer
You probably fetched the work item with only part of its properties, you can use IItemManager.fetchCompleteState() to get the full item in its historical state. If you want to get the full history you can also get all state handles at once using IItemManager.fetchAllStateHandles() instead of walking the history using IAuditable.getPredecessorState().
Regards,
Christof
Jazz Work Item team
Regards,
Christof
Jazz Work Item team
6 other answers
Thanks Christof! What you suggested worked great!
I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)
Thanks!
Annie
I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)
Thanks!
Annie
Comments
Hi Annie
I am trying to do the same thing i.e. fetch the previous states the work itemsusing IItemManager.fetchAllStateHandles() and I am getting the number of instances equal to the number of the times work item saved. However , I can not fetch the work item states of each instance.
Could you please help on this.
I am using RTC version 3.0, and accessing JAVA api.
I am facing the following problem while trying to fetch the enumerations:
Code snippet:
IEnumeration<IPriority> enums = (IEnumeration<IPriority>)workItemClient.resolveEnumeration(attribute, null);
Also, the same error occurs, while doing following operation:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", new SysoutProgressMonitor());
Exception in thread "main" java.lang.IllegalArgumentException
at com.ibm.team.process.internal.common.util.AbstractProcess.computeConfigurationData(AbstractProcess.java:328)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:313)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:299)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:68)
at com.ibm.team.workitem.common.internal.EnumerationManager$InternalEnumerations.resolve(EnumerationManager.java:52)
at com.ibm.team.workitem.common.internal.EnumerationManager.updateCache(EnumerationManager.java:198)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:117)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:74)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
at com.ibm.team.workitem.common.internal.EnumerationManager.internalResolve(EnumerationManager.java:173)
at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:169)
at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:453)
at CreateWorkItem.main(CreateWorkItem.java:147)
I am facing the following problem while trying to fetch the enumerations:
Code snippet:
IEnumeration<IPriority> enums = (IEnumeration<IPriority>)workItemClient.resolveEnumeration(attribute, null);
Also, the same error occurs, while doing following operation:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", new SysoutProgressMonitor());
Exception in thread "main" java.lang.IllegalArgumentException
at com.ibm.team.process.internal.common.util.AbstractProcess.computeConfigurationData(AbstractProcess.java:328)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:313)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:299)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:68)
at com.ibm.team.workitem.common.internal.EnumerationManager$InternalEnumerations.resolve(EnumerationManager.java:52)
at com.ibm.team.workitem.common.internal.EnumerationManager.updateCache(EnumerationManager.java:198)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:117)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:74)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
at com.ibm.team.workitem.common.internal.EnumerationManager.internalResolve(EnumerationManager.java:173)
at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:169)
at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:453)
at CreateWorkItem.main(CreateWorkItem.java:147)
Hello Christof,
I recently went through this post while trying to search any article that explains on reporting out of the history details. This post seems something similar. I would like to start writing reports that can fetch the changes of a work item along with the state changes. Could you please if there is a way I can achieve this, if so how?
Many Thanks,
Regards,
Sunita
I recently went through this post while trying to search any article that explains on reporting out of the history details. This post seems something similar. I would like to start writing reports that can fetch the changes of a work item along with the state changes. Could you please if there is a way I can achieve this, if so how?
Many Thanks,
Regards,
Sunita
Thanks Christof! What you suggested worked great!
I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)
Thanks!
Annie
We would fetch the user id from the predecessor state of a work-item.
We are using the code below:
ITeamRepository repo = ...
IWorkItem wi = ...
IAuditable predecessorState = repo.itemManager().fetchCompleteState(wi.getPredecessorState(), null);
IContributorHandle contributorH = predecessorState.getModifiedBy();
IContributor contributor = (IContributor) repo.itemManager().fetchCompleteItem(contributorH, IItemManager.DEFAULT, null);
String userId = contributor.getUserId());
But the userId is coming from the last contributor who changed the work-item's state, not from the predeccessor... Any advice?
Thanks in advance.